
#include <Wire.h> 

#define MCP23009_ADDR 0x20    // pin 1 is connected to ground, making it address x70, but we have to shift it right one bit because wiring automatically populates the LSB
#define REGISTER_OUTPUT (2)


void setup() 
{ 
  Wire.begin();        // join i2c bus (address optional for master) 
  Wire.beginTransmission(MCP23009_ADDR);
  Wire.send(0);   // address byte, 0 is for the command register
  byte cmd = 0x00;    // dynamic mode, bank 0 not blanked, bank 1 not blanked
  Wire.send(cmd);
  Wire.endTransmission();
  delay(100);
} 

void loop() 
{
  Wire.beginTransmission(MCP23009_ADDR);
  Wire.send(0x09);   // address byte, 0 is for the command register
  byte cmd = 0xff;    // dynamic mode, bank 0 not blanked, bank 1 not blanked
  Wire.send(cmd);
  Wire.endTransmission();
  delay(100);

} 




